<?php

class ArticleController extends Controller {

    public function actionIndex() {
        $models = self::$pageData;
        $this->pageTitle = '';
        $criteria = new CDbCriteria();
        $criteria->compare('page_type', self::$pageType);
        $criteria->order = 'page_sort';
        $count = Articles::model()->count($criteria);
        $pages = new CPagination($count);
        $pages->pageSize = 10;
        $pages->applyLimit($criteria);
        $models = Articles::model()->findAll($criteria);
        $this->render(self::$pageType, array('models' => $models, 'pages' => $pages));
    }

    public function actionAbout() {
        $model = self::$pageData;
        $breadCrumbs['Главная'] = '/';
        if ($model['page_type'] == 'contact' && count(explode('/', $model['page_url'])) >= 2) {
            $breadCrumbs['Контакты'] = 'contacts';
            $breadCrumbs[$model['page_title']] = 'contacts';
        } else {
            $breadCrumbs[$model['page_title']] = '/';
        }
        $this->breadcrumbs = $breadCrumbs;
        $this->render('about', array('model' => $model));
    }

    public function actionView() {
        $model = self::$pageData;
        $this->render('view', array('model' => $model));
    }

}
